package com.hckj.medical.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hckj.medical.entity.UserInfo;
import com.hckj.medical.mapper.UserInfoMapper;
import com.hckj.medical.service.IUserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author hckj
 * @since 2023-11-25
 */
@Service
public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo> implements IUserInfoService {
    @Autowired
    private UserInfoMapper userInfoMapper;
    @Override
    public Map selectByid(Integer id) {
        return userInfoMapper.selectByUid(id);
    }

    @Override
    public UserInfo selectUserInfoByid(Integer id) {
        return userInfoMapper.selectById(id);
    }

    @Override
    public List<UserInfo> findUserInfoByid(Integer id) {
        return userInfoMapper.findUserInfoByid(id);
    }

    @Override
    public Page<Map> findAll(Map map) {
        int pageNo = Integer.parseInt(map.get("pageNo").toString());
        int pageSize = Integer.parseInt(map.get("pageSize").toString());
        Page<Map> page = new Page<>(pageNo,pageSize);
        return userInfoMapper.selectUser(page,map);
    }

    @Override
    public void deletesByid(List<Integer> del) {
        userInfoMapper.deleteBatchIds(del);
    }

    @Override
    public void updateByIdentity(UserInfo userInfo) {
        LambdaQueryWrapper<UserInfo> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(UserInfo::getIdentity,userInfo.getIdentity());
        userInfoMapper.update(userInfo,wrapper);
    }

    @Override
    public List<UserInfo> findAllByname() {

        return userInfoMapper.selectList(null);
    }

    @Override
    public Integer insertUserinfo(UserInfo userInfo) {
        return userInfoMapper.insert(userInfo);
    }
}
